#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll t,n,m,l,s,sum,ans;
ll d[200005],v[200005],a[200005],p[200005];
ll bo[30];
vector<ll> q[30];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);

    cin>>t;
    while(t--)
    {
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        memset(bo,0,sizeof(bo));
        n=0;
        m=0;
        l=0;
        s=0;
        cin>>n>>m>>l>>s;
        sum=0;
        ans=m;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)
            cin>>p[i];
        sort(p+1,p+1+m);
        if(n<=20)
        {
            ans=0;
            for(int i=1;i<=m;i++)
            {
                for(int j=1;j<=n;j++)
                {
                    ll dd=v[j]*v[j]+2*a[j]*(p[i]-d[j]);
                    if(p[i]<d[j]||dd<=0)
                        continue;
                    double vv=double(sqrt(dd));
                    if(vv>double(s))
                    {
                        if(!bo[j])
                            sum++;
                        bo[j]++;
                        q[i].push_back(j);
                    }
                }
            }
            cout<<sum<<" ";
            for(int i=1;i<=m;i++)
            {
                bool flag=0;
                for(int j=0;j<q[i].size();j++)
                {
                    if(bo[q[i][j]]<=1)
                        flag=1;
                }
                if(!flag)
                {
                    ans++;
                    for(int j=0;j<q[i].size();j++)
                        bo[q[i][j]]--;
                }
                q[i].clear();
            }
            cout<<ans<<endl;
            continue;
        }
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)
            {
                if(v[i]>s&&d[i]<=p[m])
                {
                    ans=m-1;
                    sum++;
                }
            }
            if(a[i]>0)
            {
                double dd=double(d[i])+(s*s-v[i]*v[i])/(2*a[i]);
                if(dd<p[m]&&d[i]<=p[m])
                {
                    ans=m-1;
                    sum++;
                }
            }
        }
        cout<<sum<<" "<<ans<<endl;
    }
    return 0;
}

